feat(core): Add API to clear scope feature flags#5426
Open
adinauer wants to merge 2 commits into
Open
Conversation
Allow feature flags stored on a scope to be cleared without resetting other scope data. Scope.clear now also resets the feature flag buffer so stale flag evaluations do not carry over after clearing a scope. Fixes #5422 Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 319f256 | 317.53 ms | 370.83 ms | 53.29 ms |
| ab8a72d | 316.24 ms | 356.38 ms | 40.14 ms |
| cf708bd | 434.73 ms | 502.96 ms | 68.22 ms |
| 91bb874 | 310.68 ms | 359.24 ms | 48.56 ms |
| f634d01 | 375.06 ms | 420.04 ms | 44.98 ms |
| 62b579c | 299.75 ms | 364.84 ms | 65.09 ms |
| 6b019b7 | 403.90 ms | 546.09 ms | 142.19 ms |
| d364ace | 384.53 ms | 453.51 ms | 68.98 ms |
| 5b66efd | 308.67 ms | 363.85 ms | 55.18 ms |
| ee35ac3 | 346.83 ms | 435.48 ms | 88.65 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 319f256 | 1.58 MiB | 2.19 MiB | 619.79 KiB |
| ab8a72d | 1.58 MiB | 2.12 MiB | 551.55 KiB |
| cf708bd | 1.58 MiB | 2.11 MiB | 539.71 KiB |
| 91bb874 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| f634d01 | 1.58 MiB | 2.10 MiB | 533.40 KiB |
| 62b579c | 0 B | 0 B | 0 B |
| 6b019b7 | 0 B | 0 B | 0 B |
| d364ace | 1.58 MiB | 2.11 MiB | 539.75 KiB |
| 5b66efd | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| ee35ac3 | 1.58 MiB | 2.13 MiB | 558.77 KiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Add
IScope.clearFeatureFlags()to clear feature flag evaluations stored on a scope.This also makes
Scope.clear()reset the feature flag buffer, matching the existing expectation that clearing a scope returns it to its default state.💡 Motivation and Context
Fixes #5422
Refs JAVA-512
Previously, feature flag evaluations could only be added or overwritten by name. There was no way to remove evaluations that no longer apply, which could leave stale feature flags attached to later error events after an app account switch.
💚 How did you test it?
./gradlew :sentry:test --tests 'io.sentry.ScopeTest' --tests 'io.sentry.featureflags.FeatureFlagBufferTest' --tests 'io.sentry.featureflags.SpanFeatureFlagBufferTest'./gradlew spotlessApply apiDump📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Docs can be updated separately if we want to document the new scope-level clearing API.